package com.yaozheng.vocationaltraining.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.yaozheng.vocationaltraining.activity.BaseActivity;
import com.yaozheng.vocationaltraining.utils.TypeUtils;
import com.yaozheng.vocationaltraining.view.ItemMyExperienceTitle;
import com.yaozheng.vocationaltraining.view.ItemMyExperienceTitle_;

import net.sf.json.JSONArray;

/**
 * 我的经验头衔设备器
 */
public class MyExperienceTitleAdapter extends BaseAdapter {
    JSONArray dataList;
    BaseActivity baseActivity;
    int experience;

    public MyExperienceTitleAdapter(JSONArray dataList, BaseActivity baseActivity) {
        this.dataList = dataList;
        this.baseActivity = baseActivity;
    }

    public void setExperience(int experience) {
        this.experience = experience;
    }

    @Override
    public int getCount() {
        return TypeUtils.getJsonArraySize(dataList);
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ItemMyExperienceTitle itemMyExperienceTitle;
        if (convertView == null) {
            itemMyExperienceTitle = ItemMyExperienceTitle_.build(baseActivity);
        } else {
            itemMyExperienceTitle = (ItemMyExperienceTitle) convertView;
        }
        itemMyExperienceTitle.loadData(TypeUtils.getJsonObject(dataList, position), position,experience);
        return itemMyExperienceTitle;
    }
}
